var first=""
var date1=""

$(function () {
    $("#equals").click(function () {
        first="-";
        Date_get();
        $("#date1").css("display","")
        $("#datetime").css("display","none")
    })

    $("#big").click(function () {
        first=">";
        Date_get();
        $("#date1").css("display","")
        $("#datetime").css("display","none")
    })

    $("#small").click(function () {
        first="<";
        Date_get();
        $("#date1").css("display","")
        $("#datetime").css("display","none")
    })

    $("#interval").click(function () {
        first="~";
        layui.use('laydate', function() {
            var laydate = layui.laydate;
            // 加载 laydate 实例
            laydate.render({
                elem: "#date1",//绑定id为date1的元素  必填项，用于执行绑定日期渲染的元素，值一般为选择器，或DOM对象
                range:true,
                theme:"#00BFFF",
                format: 'yyyy-MM-dd',
                done: function(value, date, endDate){
                    vars = value.split("-")
                    value1 =""
                    for(var i=0;i<vars.length;i++){
                        if (i==2){
                            value1 = value1 + vars[i] +","
                        }else if (i==5){
                            value1 = value1 + vars[i]
                        } else {
                            value1 = value1 + vars[i] +"-"
                        }
                    }
                    date1=value1;
                    console.log(value1);
                }
            })
        })
        $("#date1").css("display","")
        $("#datetime").css("display","none")
    })
})

Date_get = function () {
    layui.use('laydate', function() {
        var laydate = layui.laydate;
        // 加载 laydate 实例
        laydate.render({
            elem: "#date1",//绑定id为date1的元素  必填项，用于执行绑定日期渲染的元素，值一般为选择器，或DOM对象
            theme:"#00BFFF",
            done: function(value, date, endDate){
                console.log(value); //得到日期生成的值，如：2017-08-18
                date1=value;
            }
        })
    })
}